package com.jliang.apps.config;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

@Configuration
public class RestTemplateConfig {
	 
	 @Bean
	 @Qualifier("restTemplateA")
	 public RestTemplate restTemplateA(){
		 SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();  
		 requestFactory.setConnectTimeout(1000);  
		 requestFactory.setReadTimeout(1000);  
		 RestTemplate restTemplate = new RestTemplate(requestFactory);  
		 return restTemplate;
	 }
	 
	 @Bean
	 @Qualifier("restTemplateB")
	 public RestTemplate restTemplateB(){
		 SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();  
		 requestFactory.setConnectTimeout(2000);  
		 requestFactory.setReadTimeout(2000);  
		 RestTemplate restTemplate = new RestTemplate(requestFactory);  
		 return restTemplate;
	 }
}
